#include "Rais_Utils.h"

//hast'n been finished
//solving Cubic Equation : ax^3 + bx^2 + cx + d = 0
/*
void solveCubicEqua(double solution[], double a, double b, double c, double d){
	if(a == 0){
		solveQuadEqua(solution, b, c, d);
		return;
	}
	double A = r_sq(b) - 3 * a * c;
	double B = b * c  - 9 * a * d;
	
	if(A == 0 && A == B){
		solution[0] = -c / b;
		solution[1] = solution[0];
		solution[2] = solution[0];
		return;
	}
	
	double C = r_sq(c) - 3 * b * d;
	double Delta = r_sq(B) - 4 * A * C;
	
	if(Delta > 0){	
		double Y1 = A * b + 3 * a * (-B + sqrt(Delta)) / 2;
		double Y2 = A * b + 3 * a * (-B - sqrt(Delta)) / 2;
		
		solution[0] = (-b - (pow(Y1, 1.0/3) + pow(Y2, 1.0/3) ) ) / (3 * a);
		solution[1] = NAN;	//a imaginary number
		solution[2] = NAN;	//a imaginary number, and it's solution[1]'s conjugate imaginary number
		return;
	}
	if(Delta == 0){		
		double K = B / A;
		
		solution[0] = -b / a + K;
		solution[1] = -K / 2;
		solution[2] = solution[1];
		return;
	}
	if(Delta < 0){
		double theta = acos((2 * A * b - 3 * a * B) / (2 * sqrt(r_cb(A) ) ) );
		solution[0] = (-b - 2 * sqrt(A) * cos(theta / 3) ) / (3 * a);
		solution[1] = (-b + sqrt(A) * (cos(theta / 3) + sqrt(3) * sin(theta / 3) ) ) / (3 * a);
		solution[2] = (-b + sqrt(A) * (cos(theta / 3) - sqrt(3) * sin(theta / 3) ) ) / (3 * a);
	}
}*/


/*class Vector:

//返回向量大小
inline double r_abs(const Vector& v){
	return hypot(v.x, v.y);
}

//共线判断
inline bool collinear(const Vector& v1, const Vector& v2){
	return v1.x * v2.y - v2.x * v1.y == 0;
}


Vector::Vector(double x, double y){
	this->x = x;
	this->y = y;
}

Vector::Vector(const Vector& v){
	this->x = v.x;
	this->y = v.y;
}

Vector::Vector(){}

void Vector::set(double x, double y){
	this->x = x;
	this->y = y;
}

void Vector::operator=(const Vector& v){
	x = v.x;
	y = v.y;
}


//向量加减
Vector Vector::operator+(const Vector& v){
	return Vector(x + v.x, y + v.y);
}
Vector Vector::operator-(const Vector& v){
	return Vector(x - v.x, y - v.y);
}
void Vector::operator+=(const Vector& v){
	x += v.x;
	y += v.y;
}
void Vector::operator-=(const Vector& v){
	x -= v.x;
	y -= v.y;
}

//数乘
Vector Vector::operator*(double l){
	return Vector(x * l, y * l);
}
void Vector::operator*=(double l){
	x *= l;
	y *= l;
}

//数量积
double Vector::operator*(const Vector& v){
	return x * v.x + y * v.y;
}

//相等向量判断
bool Vector::operator==(const Vector& v){
	return x == v.x && y == v.y;
}

//模大小比较
bool Vector::operator>(const Vector& v){
	return r_abs(*this) > r_abs(v);
}
bool Vector::operator<(const Vector& v){
	return r_abs(*this) < r_abs(v);
}
bool Vector::operator>=(const Vector& v){
	return r_abs(*this) >= r_abs(v);
}
bool Vector::operator<=(const Vector& v){
	return r_abs(*this) <= r_abs(v);
}

Vector Vector::operator~(){
	x = -x;
	y = -y;
	return *this;
}
*/
